import { CACHE_KEY, useCache } from './web/useCache'

/**
 * @author        hejiyang <silentmanager@163.com>
 * @date          2024-12-01 22:19:14
 * Copyright © YourCompanyName All rights reserved
 */
export function useReadTeam() {
  const { wsCache } = useCache()
  const permissions = wsCache.get(CACHE_KEY.USER).permissions
  const readTeam = permissions.includes('crm:statistics:by-dept')
  return {
    readTeam
  }
}

export function usePermissions(code: string) {
  const { wsCache } = useCache()
  const permissions = wsCache.get(CACHE_KEY.USER).permissions
  const hasPermissions = permissions.includes(code)
  return {
    hasPermissions
  }
}
